<html>

<head>
  <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  <meta name="referrer" content="never">
  <title>bilibili-parse播放测试</title>
  <link rel="shortcut icon" href="favicon.png">
</head>

<body>
  <div id="dplayer1"></div>

  <script src="/static/study/DPlayer.min.js"></script>
  <script>
    const params = window.location.search.substring(1).split('&')
    const map = {
      av: '', bv: '', p: '1'
    }
    for (let i = 0; i < params.length; i++) {
      const pair = params[i].split('=')
      map[pair[0]] = pair[1]
    }
    fetch(`./index.php?av=${map['av']}&bv=${map['bv']}&p=${map['p']}&format=mp4`).then(res => {
      if (res.ok) {
        res.json().then(data => {
          new DPlayer({
            container: document.getElementById('dplayer1'),
            video: {
              url: data.url.replace(/^https?\:\/\//i, 'https://'),
              type: 'auto'
            }
          })
        })
      }
    })
  </script>
</body>

</html>
